package com.xitang.common.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xitang.common.bean.BizProductDetail;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BizProductDetailMapper extends BaseMapper<BizProductDetail> {
    @Select("select * from biz_product where biz_product.product_code = #{product_code}")
    @Results(
            @Result(
                    property = "materialList", column = "product_code",
                    javaType = List.class,
                    many = @Many(select = "com.xitang.common.mapper.BizMaterialMapper.returnMaterials")
            )
    )
    BizProductDetail selectProductAndMaterials(@Param("product_code") String productCode);
}